(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

f(0) → cons(0, n__f(s(0)))
f(s(0)) → f(p(s(0)))
p(s(X)) → X
f(X) → n__f(X)
activate(n__f(X)) → f(X)
activate(X) → X

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, 1).


The TRS R consists of the following rules:

f(0) → cons(0, n__f(s(0))) [1]
f(s(0)) → f(p(s(0))) [1]
p(s(X)) → X [1]
f(X) → n__f(X) [1]
activate(n__f(X)) → f(X) [1]
activate(X) → X [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(0) → cons(0, n__f(s(0))) [1]
f(s(0)) → f(p(s(0))) [1]
p(s(X)) → X [1]
f(X) → n__f(X) [1]
activate(n__f(X)) → f(X) [1]
activate(X) → X [1]

The TRS has the following type information:
f :: 0:s → n__f:cons
0 :: 0:s
cons :: 0:s → n__f:cons → n__f:cons
n__f :: 0:s → n__f:cons
s :: 0:s → 0:s
p :: 0:s → 0:s
activate :: n__f:cons → n__f:cons

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

p(v0) → null_p [0]

And the following fresh constants:

null_p, const

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(0) → cons(0, n__f(s(0))) [1]
f(s(0)) → f(p(s(0))) [1]
p(s(X)) → X [1]
f(X) → n__f(X) [1]
activate(n__f(X)) → f(X) [1]
activate(X) → X [1]
p(v0) → null_p [0]

The TRS has the following type information:
f :: 0:s:null_p → n__f:cons
0 :: 0:s:null_p
cons :: 0:s:null_p → n__f:cons → n__f:cons
n__f :: 0:s:null_p → n__f:cons
s :: 0:s:null_p → 0:s:null_p
p :: 0:s:null_p → 0:s:null_p
activate :: n__f:cons → n__f:cons
null_p :: 0:s:null_p
const :: n__f:cons

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 0
null_p => 0
const => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

activate(z) -{ 1 }→ X :|: X >= 0, z = X
activate(z) -{ 1 }→ f(X) :|: z = 1 + X, X >= 0
f(z) -{ 1 }→ f(p(1 + 0)) :|: z = 1 + 0
f(z) -{ 1 }→ 1 + X :|: X >= 0, z = X
f(z) -{ 1 }→ 1 + 0 + (1 + (1 + 0)) :|: z = 0
p(z) -{ 1 }→ X :|: z = 1 + X, X >= 0
p(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V),0,[f(V, Out)],[V >= 0]).
eq(start(V),0,[p(V, Out)],[V >= 0]).
eq(start(V),0,[activate(V, Out)],[V >= 0]).
eq(f(V, Out),1,[],[Out = 3,V = 0]).
eq(f(V, Out),1,[p(1 + 0, Ret0),f(Ret0, Ret)],[Out = Ret,V = 1]).
eq(p(V, Out),1,[],[Out = X1,V = 1 + X1,X1 >= 0]).
eq(f(V, Out),1,[],[Out = 1 + X2,X2 >= 0,V = X2]).
eq(activate(V, Out),1,[f(X3, Ret1)],[Out = Ret1,V = 1 + X3,X3 >= 0]).
eq(activate(V, Out),1,[],[Out = X4,X4 >= 0,V = X4]).
eq(p(V, Out),0,[],[Out = 0,V1 >= 0,V = V1]).
input_output_vars(f(V,Out),[V],[Out]).
input_output_vars(p(V,Out),[V],[Out]).
input_output_vars(activate(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [p/2]
1. recursive : [f/2]
2. non_recursive : [activate/2]
3. non_recursive : [start/1]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into p/2
1. SCC is partially evaluated into f/2
2. SCC is partially evaluated into activate/2
3. SCC is partially evaluated into start/1

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations p/2
* CE 8 is refined into CE [12]
* CE 9 is refined into CE [13]


### Cost equations --> "Loop" of p/2
* CEs [12] --> Loop 9
* CEs [13] --> Loop 10

### Ranking functions of CR p(V,Out)

#### Partial ranking functions of CR p(V,Out)


### Specialization of cost equations f/2
* CE 7 is refined into CE [14]
* CE 5 is refined into CE [15]
* CE 6 is refined into CE [16,17]


### Cost equations --> "Loop" of f/2
* CEs [16,17] --> Loop 11
* CEs [14] --> Loop 12
* CEs [15] --> Loop 13

### Ranking functions of CR f(V,Out)

#### Partial ranking functions of CR f(V,Out)


### Specialization of cost equations activate/2
* CE 10 is refined into CE [18,19,20,21]
* CE 11 is refined into CE [22]


### Cost equations --> "Loop" of activate/2
* CEs [21,22] --> Loop 14
* CEs [20] --> Loop 15
* CEs [19] --> Loop 16
* CEs [18] --> Loop 17

### Ranking functions of CR activate(V,Out)

#### Partial ranking functions of CR activate(V,Out)


### Specialization of cost equations start/1
* CE 2 is refined into CE [23,24,25,26]
* CE 3 is refined into CE [27,28]
* CE 4 is refined into CE [29,30,31,32]


### Cost equations --> "Loop" of start/1
* CEs [30,31] --> Loop 18
* CEs [24,25,29] --> Loop 19
* CEs [23,26,27,28,32] --> Loop 20

### Ranking functions of CR start(V)

#### Partial ranking functions of CR start(V)


Computing Bounds
=====================================

#### Cost of chains of p(V,Out):
* Chain [10]: 0
with precondition: [Out=0,V>=0]

* Chain [9]: 1
with precondition: [V=Out+1,V>=1]


#### Cost of chains of f(V,Out):
* Chain [13]: 1
with precondition: [V=0,Out=3]

* Chain [12]: 1
with precondition: [V+1=Out,V>=0]

* Chain [11,13]: 3
with precondition: [V=1,Out=3]

* Chain [11,12]: 3
with precondition: [V=1,Out=1]


#### Cost of chains of activate(V,Out):
* Chain [17]: 2
with precondition: [V=1,Out=3]

* Chain [16]: 4
with precondition: [V=2,Out=1]

* Chain [15]: 4
with precondition: [V=2,Out=3]

* Chain [14]: 2
with precondition: [V=Out,V>=0]


#### Cost of chains of start(V):
* Chain [20]: 2
with precondition: [V>=0]

* Chain [19]: 3
with precondition: [V=1]

* Chain [18]: 4
with precondition: [V=2]


Closed-form bounds of start(V):
-------------------------------------
* Chain [20] with precondition: [V>=0]
- Upper bound: 2
- Complexity: constant
* Chain [19] with precondition: [V=1]
- Upper bound: 3
- Complexity: constant
* Chain [18] with precondition: [V=2]
- Upper bound: 4
- Complexity: constant

### Maximum cost of start(V): 4
Asymptotic class: constant
* Total analysis performed in 74 ms.

(10) BOUNDS(1, 1)